<template>
  <div class="chat-page">
    <div class="side-panel">
      <HistoryPanel />
    </div>
    <div class="main-panel">
      <div class="chat-container" :class="{ 'loading': isLoading }">
        <ChatPanel 
          :is-loading="isLoading"
          @update:is-loading="updateLoadingState"
        />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';
import { storeToRefs } from 'pinia';
import ChatPanel from '../components/ChatPanel.vue';
import HistoryPanel from '../components/HistoryPanel.vue';
import { useHistoryStore } from '../stores/history';

const historyStore = useHistoryStore();
const { isLoading: storeLoading } = storeToRefs(historyStore);
const isLoading = computed(() => storeLoading.value);

// 更新加载状态
const updateLoadingState = (value) => {
  historyStore.isLoading = value;
};
</script>

<style scoped>
.chat-page {
  display: flex;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background-color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.side-panel {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid #ebeef5;
  background-color: rgba(246, 248, 250, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease;
}

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-container {
  flex: 1;
  overflow: hidden;
  transition: filter 0.3s ease, opacity 0.3s ease;
}

.chat-container.loading {
  filter: blur(2px);
  opacity: 0.7;
  pointer-events: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .side-panel {
    width: 250px;
  }
}

@media (max-width: 576px) {
  .chat-page {
    flex-direction: column;
  }
  
  .side-panel {
    width: 100%;
    height: 40%;
    min-height: 300px;
    border-right: none;
    border-bottom: 1px solid #ebeef5;
  }
  
  .main-panel {
    height: 60%;
  }
}
</style> 